package com.sunnyweather.android.ui.weather

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
import com.sunnyweather.android.logic.util.LogUtil

//使用广播来解决Activity与Service之间的通信问题
class WeatherReceiver : BroadcastReceiver() {

    private val activity=WeatherActivity.runningInstance
    override fun onReceive(context: Context, intent: Intent) {
        // This method is called when the BroadcastReceiver is receiving an Intent broadcast.
        LogUtil.d("WeatherReceiver","")
        activity?.weatherViewModel?.getWeather()
    }
}